<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"
	import="java.util.*,java.sql.*,com.telecom.cms.dao.*,com.telecom.cms.dbconnect.*,com.telecom.cms.dto.*"%>

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link rel="stylesheet" type="text/css" href="images/main.css">
		<title>CMS批量提取功能</title>
		<STYLE type=text/css>
BODY {
	SCROLLBAR-FACE-COLOR: #f2f2f2;
	SCROLLBAR-HIGHLIGHT-COLOR: #f2f2f2;
	SCROLLBAR-SHADOW-COLOR: #b7b7b7;
	SCROLLBAR-3DLIGHT-COLOR: #f2f2f2;
	SCROLLBAR-ARROW-COLOR: #999999;
	SCROLLBAR-TRACK-COLOR: #e9e9e9;
	SCROLLBAR-DARKSHADOW-COLOR: #f2f2f2;
	SCROLLBAR-BASE-COLOR: #f2f2f2
}
</style>
		<script type="text/javascript" language="javascript">
		function f(){
		
		
		     var r = document.form1.type;  
		
		     var testarar = document.form1.textarea.value;
		     
		     
		     
		     var bcy = document.form1.billing_cycle_y.value; 
		     var bcm = document.form1.billing_cycle_m.value;
    
		     if(testarar.length == 0){
		     
		           alert("请在文本框中贴入数据");
		           return false ;
		     }
		     if(testarar.indexOf("'")!= -1){
		     
		             alert("贴入数据格式不正确");
		           return false ;  
		     
		     
		     }
		     
		      if(bcy==00||bcm==00){
          
               
              alert("请定制账务月!!"); 
              return   false;      
          
          
          } 
            var   j=0;   
            for(i=0;i<r.length;i++){   
              if(r[i].checked)
              j++;   
              }  
            if(j<1){   
             alert("请定制批量提取的结果字段!!");   
             return   false;   
              } 
              
          	if(confirm("提交本次批量提取!"))
	         {
		     return true;
	           }
	         else
	         {
		       return false;
	}    
              
          
            
		}
	function checkAll(str) 
{ 
  var a = document.getElementsByName(str); 
  var n = a.length; 
  for (var i=0; i<n; i++) 
     a[i].checked = window.event.srcElement.checked; 
} 

function checkItemMul(str) 
{ 
    var e = window.event.srcElement; 
    var all = eval("document.form1."+ str); 
    var i=0,j=0;
    for(i=0;i<all.length;i++)
      if(all[i].value==e.name)
        j=i;
        
    var a = document.getElementsByName(e.name); 
    if (all.length>1)
       all[j].checked = false; 
    else
       all.checked = false;
    for (i=0; i<a.length; i++) 
    { 
       if (a[i].checked)
       { 
         if (all.length>1)
            all[j].checked = true; 
         else
            all.checked = true;
         break;
       } 
    } 
}  
	function querymodel(o){
			if(o.value==0){
				window.location.href="result.jsp";
			}else{
			document.form1.action="atomGet4RSModelDEF.do"
			document.getElementById("operation").value="scorepicklist";
			document.form1.submit();
			}
		}	
		
		
		
		</script>
	</head>
	<body>
		<TABLE height=67 cellSpacing=0 cellPadding=0 width="100%" border=0>
			<TBODY>
				<TR>

					<TD width="6%"></TD>
					<TD vAlign=middle noWrap>
						<img src="images/cms_logo.jpg">
					</TD>
					<TD vAlign=top align=center width="61%">
						<img src="images/teradata_logo.gif">
					</TD>
				</TR>
			</TBODY>
		</TABLE>
		<hr>
		<form name="form1" action="pickup.do" onSubmit="return f()"
			method="post">

			<table width="975" cellspacing="0" cellpadding="0" border="0"
				align="center">
				<tbody>
					<tr>
						<td width="3" height="31">
							<img height="31" src="images/table_01.gif" width="3" />
						</td>
						<td background="images/table_02.gif" colspan="2" height="31"
							valign="baseline">
							<table cellspacing="0" cellpadding="0" width="146" align="left"
								border="0" height="1">
								<tbody>
									<tr>
										<td width="51" background="images/title_1_bg.gif">
											<img height="31" src="images/title_1.gif" width="51" />
										</td>
										<td width="95" background="images/title_1_bg.gif">
											<span class="color_b_666">反查条件定制</span>
										</td>
									</tr>
								</tbody>
							</table>
							<center>
						</td>
						<td width="3">
							<img height="31" src="images/table_03.gif" width="3" />
						</td>
					</tr>
					<tr>
						<td height="172">
							<img height="100%" src="images/table_04.gif" width="3" />
						</td>
						<td style="PADDING-TOP: 3px" valign="top" colspan="2">

							<table width="879" height="129" border="0" align="left"
								cellpadding="1" cellspacing="1" class="moduleList">
								<tr>
									<td width="50%" align="left" valign="top">
										选择号码的类型
										<input type="radio" name="radiobutton" value="Acct_Id">
										账户标识
										<input type="radio" name="radiobutton" value="Cust_Id">
										客户标识
										<input type="radio" name="radiobutton" value="Accs_Nbr"
											checked>
										接入号码
										<%
										String numtype = (String) request.getAttribute("numtype");
										if (numtype != null) {
									%>
										<script type="text/javascript">
											button=document.getElementsByName("radiobutton");
											for(i=0;i<3;i++){
												if(button[i].value=="<%=numtype%>"){
													button[i].checked=true;
												}
											}
										</script>
										<%
											}
											Calendar myCalendar = Calendar.getInstance();
										%>
									</td>

									<td width="40%" align="left" valign="top">
										选择账务月
										<select name="billing_cycle_y">
											<%
												for (int myYear = 2006; myYear < 2010; myYear++) {
											%>
											<option value="<%=myYear%>"
												<%=(myCalendar.get(1) == myYear ? "selected" : "")%>>
												<%=myYear%>
											</option>
											<%
												}
											%>
										</select>
										<%
											String bcy = (String) request.getAttribute("bcy");
											if (bcy != null) {
										%>
										<script type="text/javascript">document.all.billing_cycle_y.value=<%=bcy%></script>
										<%
											}
										%>
										<select name="billing_cycle_m">
											<%
												for (int myMon = 1; myMon < 13; myMon++) {
											%>
											<option value="<%=myMon%>"
												<%=(myCalendar.get(2) == myMon ? "selected" : "")%>>
												<%=myMon%>
												月
											</option>
											<%
												}
											%>
										</select>
										<%
											String bcm = (String) request.getAttribute("bcm");
											if (bcm != null) {
										%>
										<script type="text/javascript">document.all.billing_cycle_m.value=<%=bcm%></script>
										<%
											}
										%>
									</td>
									<td width="30%" align="left" valign="top">
										<%
											String latndesc = ((String) session.getAttribute("latndesc"))
													.trim();
											out.print(latndesc);
											if (latndesc.equals("湖北省中心")) {
												out.print("请选择：");
												List latnidlist = new LOC_LATNDAO().findAll();
												Iterator i = latnidlist.iterator();

												out.print("<select name=selectlatnid>");

												while (i.hasNext()) {
													LOC_LATNDTO dto = (LOC_LATNDTO) (i.next());
													String id = dto.getLatn_id();
													if (id.equals("1000")) {
														continue;
													}
													String desc = dto.getLatn_desc();
													out.print("<option value=" + id + ">" + desc + "</option>");
												}
												out.print("</select>");

											}
											String selectlatnid = (String) request.getAttribute("selectlatnid");
											if (bcy != null) {
										%>
										<script type="text/javascript">document.all.selectlatnid.value=<%=selectlatnid%></script>
										<%
											}
										%>
									</td>
								</tr>
								<tr>
									<td colspan="3">
										<b>CMS号码反查文本域</b>(输入格式为每个号码单独一行，用换行分开，不用其他字符分隔，可直接从EXCEL文件中将号码复制后粘贴到下面)：
									</td>
								</tr>
								<tr>
									<td colspan="3">
										<textarea name="textarea" cols="116" rows="20"
											title="CMS批量提取文本域(请将文本记录复制粘贴到这里)"><%=null == (String) request
							.getAttribute("textnum") ? "" : (String) request
							.getAttribute("textnum")%></textarea>
									</td>
								</tr>

							</table>
						</td>
						<td background="images/table_05.gif">
							<img height="53" src="images/table_05.gif" width="3">
						</td>
					</tr>
					<tr>
						<td>
							<img height="12" src="images/table_06.gif" width="3">
						</td>
						<td colspan="2" height="3">
							<img height="3" src="images/table_07.gif" width="100%">
						</td>
						<td>
							<img height="12" src="images/table_08.gif" width="3">
						</td>
					</tr>
				</tbody>
			</table>



			<table width="975" cellspacing="0" cellpadding="0" border="0"
				align="center">
				<tbody>
					<tr>
						<td width="3" height="31">
							<img height="31" src="images/table_01.gif" width="3" />
						</td>
						<td background="images/table_02.gif" height="31" valign="baseline">
							<table cellspacing="0" cellpadding="0" width="146" align="left"
								border="0" height="1">
								<tbody>
									<tr>
										<td width="51" background="images/title_1_bg.gif">
											<img height="31" src="images/title_1.gif" width="51" />
										</td>
										<td width="95" background="images/title_1_bg.gif">
											<span class="color_b_666">展示结果定制</span>
										</td>
									</tr>
								</tbody>
							</table>
							<center>
								<table align="right">
									<tr align="right">
										<td>
											<select name="templateId" onchange="querymodel(this)">
												<option value="0">
													请选择模板:
												</option>
												<%
																	Connection con = GetConnect.getCsConnection();
																	String oldid = (String) session.getAttribute("oldid");
																	IDA_TEMPLATEDAO templatedao = new IDA_TEMPLATEDAO(con);
																	List templist = templatedao.findAll("20", "admin");
																	Iterator it = templist.iterator();
																	while (it.hasNext()) {
																		IDA_TEMPLATEDTO templatedto = (IDA_TEMPLATEDTO) (it.next());
																		String templatename = templatedto.getTemplateName();
																		String templateid = templatedto.getTemplateId().toString();
												%>
												<option value="<%=templateid%>"
													<%=templateid.equals(request
										.getParameter("templateId")) ? " selected"
								: ""%>>
													<%=templatename%>
												</option>
												<%
													}
												%>
											</select>
										</td>
										<td valign="bottom" align="right">
											<input type="submit" value="提交查询" name="Submit">
										</td>
									</tr>
								</table>
							</center>
						</td>
						<td width="3">
							<img height="31" src="images/table_03.gif" width="3" />
						</td>
					</tr>
					<tr>
						<td width="3" background="images/table_04.gif" align="right">
						</td>
						<td style="PADDING-TOP: 3px" valign="top">

							<table width="879" height="129" border="0" align="left"
								cellpadding="1" cellspacing="1" class="moduleList">

								<tr>


									<%
										int j = 0;
										String kindId = (String) session.getAttribute("kindId");
										SEG_BIZ_GROUP_DEFDAO dao = new SEG_BIZ_GROUP_DEFDAO(con);
										List grouplist = dao.findAllByKind(kindId);

										for (int i = 0; i < grouplist.size(); i++) {

											SEG_BIZ_GROUP_DEFDTO groupdto = (SEG_BIZ_GROUP_DEFDTO) grouplist
													.get(i);
											SEG_ATOM_GROUP_RELDAO reldao = new SEG_ATOM_GROUP_RELDAO(con);
											List rellist = reldao.findById(groupdto.getATOM_GROUP_ID());

											if (groupdto.getATOM_GROUP_ID() == 400006) {
												continue;
											}
											List atomlist = new ArrayList();

											if (j % 4 == 0 && j != 0) {
									%>

								</tr>
								<tr>

									<%
										}
									%>

									<td width="232" align="left">
										<TABLE width="100%" height="26" border=0 cellPadding=1
											cellSpacing=1 id=table18 bgcolor=#d9e5ea>
											<TR bgColor=#d9e5ea height="26">
												<TD width="230" vAlign=top background="images/atom_02.gif">
													<SPAN class=en_big> <input type="checkbox" id="type"
															name="type" value="<%=groupdto.getATOM_GROUP_NAME()%>"
															onclick="checkAll('<%=groupdto.getATOM_GROUP_NAME()%>')">
														<%=groupdto.getATOM_GROUP_NAME()%></SPAN>
												</TD>
											</TR>
											<TR bgcolor="#FFFFFF">
												<td height="100" align=left>
													<div style="height: 100px; width: 230px; overflow-y: auto;">
														<%
																					for (int k = 0; k < rellist.size(); k++) {
																					SEG_ATOM_GROUP_RELDTO seg_ATOM_GROUP_RELDTO = (SEG_ATOM_GROUP_RELDTO) rellist
																					.get(k);
																					SEG_BIZ_ATOM_DEFDAO atomdao = new SEG_BIZ_ATOM_DEFDAO(
																					con);
																					SEG_BIZ_ATOM_DEFDTO atomdto = atomdao
																					.findById(seg_ATOM_GROUP_RELDTO.getBIZ_ATOM_ID());
																					if (atomdto.getVALUE_TYPE_ID() != 1000
																					&& atomdto.getVALUE_TYPE_ID() != 2000) {

																						atomlist.add(atomdto);
																					}
																						}
																						if (atomlist.size() > 0)
																					for (int m = 0; m < atomlist.size(); m++) {
																						SEG_BIZ_ATOM_DEFDTO showdto = (SEG_BIZ_ATOM_DEFDTO) atomlist
																						.get(m);
														%>
														<input type="checkbox"
															name=<%=groupdto.getATOM_GROUP_NAME()%>
															value="<%=showdto.getBIZ_ATOM_ID()%>"
															<%
															boolean conditionchecked=false;
															List modelDisplay=(List)request.getAttribute("modelDisplay");
															if(modelDisplay!=null){
																Iterator iter=modelDisplay.iterator();
																while(iter.hasNext()){
																int display = ((IDA_TEMPLATE_ATOM_RESULTDTO)iter.next()).getBizAtomId();
																int show = showdto.getBIZ_ATOM_ID();
																	if(show==display)
																	{
																		out.print("checked ");
																		conditionchecked=true;
																	} 
																}
															}
														%>
															onclick="checkItemMul('type')">
														<%=showdto.getBIZ_ATOM_NAME().trim()%>
														<br>
														<%
															if (conditionchecked) {
														%>
														<script type="text/javascript">
															all = document.getElementsByName('type');
															    for(i=0;i<all.length;i++)
      															if(all[i].value=='<%=groupdto.getATOM_GROUP_NAME()%>')
        														{
        															all[i].checked=true;
        														}
														</script>
														<%
															}
														%>
														<%
															}//end of form
														%>
													</div>
												</td>
											</TR>

										</TABLE>
									</td>


									<%
										j++;
										}
									%>

								</tr>
							</table>
						</td>
						<td background="./images/table_05.gif" width="3" align="left">
							<img height="100%" src="./images/table_05.gif" width="3">
						</td>
					</tr>
					<tr>
						<td height=3 valign="top">
							<img height="12px" src="./images/table_06.gif" width="3px">
						</td>
						<td height=3 valign="top">
							<img height="3px" src="./images/table_07.gif" width="100%">
						</td>
						<td height=3 valign="top">
							<img height="12px" src="./images/table_08.gif" width="3px">
						</td>
					</tr>
				</tbody>
			</table>
			<input type="hidden" id="operation" name="method" value="">
		</form>

	</body>
</html>

